let fs = require('fs');
fs.readFile('./1.txt','utf8',(err,data)=>{
    fn(data,0)
})
fs.readFile('./2.txt','utf8',(err,data)=>{
    fn(data,1)
})
fs.readFile('./3.txt','utf8',(err,data)=>{
    fn(data,2)
})


let fn=after(3,function(arr){
    console.log(arr);
});

function after(times,callback){
    let arr=[];
    return function(data,index){
         arr[index]=data;
        if(--times===0){
            callback(arr);
        }
    }
}